<template>
	<div>
		<el-divider content-position="left">权限文件初始化</el-divider>
		<div style="width:350px">
			权限文件上传:<uploadfile style="display: inline;" ref="uploadfile" v-model="file" :max="1" :sysFileList="false">
			</uploadfile>
		</div>
		<br />
		<el-button @click="initPower" v-loading="loading">权限文件上传</el-button>
		<br /><br />
		<el-divider content-position="left">EF数据库检测</el-divider>
		<el-button @click="checkDb" v-loading="loading">执行</el-button>
		<br /><br />
		<el-divider content-position="left">测试mixins JS和vue文件</el-divider>
		test _uid{{_uid}}<br />
		我的count:{{count}}
		我partialjs的count:{{count2}}<br />
		<testpartial ref="testpartial" v-model="testpartial" style="width:100px;" style2="style2" @click="testClick">
			<template v-slot:add>
				<div style="color: green;">自定义按钮</div>
			</template>
			<!-- <template>
				<div style="color: green;">全部自定义按钮</div>
			</template> -->
		</testpartial>
		<br /><br />
		<el-divider content-position="left">测试图标</el-divider>
		folder-open-line:
		<vab-remix-icon icon="folder-open-line" />
		business:
		<vab-colorful-icon icon-class="business" />
		<vab-colorful-icon icon-class="https://cdn.jsdelivr.net/gh/chuzhixin/zx-colorful-icon@master/business.svg" />
		<br /><br />
	</div>
</template>

<script>
	import common from "@/common/common.js";
	import config from "@/common/config.js";
	import testpartial from "./test/testpartial.vue";
	import testpartialjs from "./test/testpartial.js";

	export default {
		name: "test",
		components: {
			testpartial
		},
		computed: {
			count() {
				return 0;
				//return this.$refs.testpartial.count;
			}
		},
		mixins: [common.baseVM, testpartialjs],
		data() {
			return {
				file: "",
				loading: false,
				testpartial: "testpartial"
			};
		},
		methods: {
			initPower() {
				if (!this.file) {
					this.showToast("请选择权限初始化文件");
					return;
				}
				var postData = this.toKeyValue({
					file: this.file
				});
				this.post('api/System/InitPower', postData).then((data) => {
					this.showToast(data.Message, "success");
					console.log("/api/system/initPower", data);

					config.loginByToken();
				});
			},
			testClick() {
				console.log("testClick");
			},
			checkDb() {
				this.confirm("确定检测?", () => {
					this.post('api/System/CheckDb').then((data) => {
						this.showToast(data.Message, "success");
					});
				});
			}
		},
	};
</script>
